<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

$origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';
$allow_origin = array(
    'http://192.168.3.13:8000',
    'http://192.168.3.13:8001',
    'http://192.168.3.51:8080',
    'http://192.168.3.51:8001',
    'http://192.168.3.51:8081',
    'http://localhost:8000',
    'http://127.0.0.1:8000',
);
if (in_array($origin, $allow_origin)) {
//    header('Access-Control-Allow-Origin:' . $origin);
}
header('Access-Control-Allow-Origin:*');

header("Access-Control-Allow-Methods:POST,GET, OPTIONS, PUT, PATCH, DELETE");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
//header("Access-Control-Allow-Credentials:true");
header("Access-Control-Max-Age:1728000");
if(strtoupper($_SERVER['REQUEST_METHOD'])== 'OPTIONS'){
    exit;
}

require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-local.php')
);

(new yii\web\Application($config))->run();
